package com.title6;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.UUID;

/**
 * @Author milian
 * @Date 2021/8/2 0002 17:42
 */
public class ServerDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(10000);
        Socket accept = serverSocket.accept();
        BufferedInputStream bufferedInputStream = new BufferedInputStream(accept.getInputStream());
        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream("H:\\homework\\day15\\src\\com\\title6\\copy.jpg"));
        int b;
        while ((b=bufferedInputStream.read())!=-1){
            bufferedOutputStream.write(b);
        }
        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
        bufferedWriter.write("上传成功");
        bufferedWriter.newLine();
        bufferedWriter.flush();

        bufferedOutputStream.close();
        accept.close();
        serverSocket.close();
    }
}
